home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr05 / mswlogo3.zip / MSWLOGO.ZIP / EXAMPLES.ZIP / VISUAL.WIN < prev   
Text File  |  1993-04-11  |  3KB  |  145 lines

  1. ;
  2. ; This Example is actually the core of (seed to) a much larger application.
  3. ; It is a visual editor for editing Logo Windows/Dialog boxes with the mouse.
  4. ; It's actaully a good seed to a Paint/Draw/Cad like application too.
  5. ; It was also a great test for flushing bugs out of MswLogo itself.
  6. ;
  7. ; Currently all that it does is:
  8. ;
  9. ; Create a "Button" (Draw it and put it in a DataBase),
  10. ; Allow you to select the "Button" with the mouse (Mouse Button down in Box).
  11. ; Allow you to drag the Box to another location and update database.
  12. ; Allow you to deselect the "Button" (Mouse Button up).
  13. ; Allow you to Erase the "Button" and remove it from the Database.
  14. ;
  15. ; Eventually it should be capable of reading in your Logo routine that
  16. ; sizes and places your buttons, modify it "Visually", and then
  17. ; write it back out. In otherwords it should be able to edit a routine
  18. ; like "dowindows" below "Visually".
  19. ;
  20.  
  21. to deletething
  22. mouseon [lbtndowndel] [] [] [] []
  23. make "mousedn "false
  24. make "boxisselected "false
  25. end
  26.  
  27. to dowindows
  28. windowcreate "root "dlg [Visual Logo] 0 0 100 100
  29. buttoncreate "dlg "end "End 0 0 25 25 [visualend]
  30. buttoncreate "dlg "new [New Button] 0 25 50 25 [newbutton] 
  31. buttoncreate "dlg "del [Delete] 0 50 50 25 [deletething] 
  32. end
  33.  
  34. to drawbox :box
  35. make "x first :box
  36. make "y first butfirst :box
  37. make "w first butfirst butfirst :box
  38. make "h last :box
  39. setxy :x :y
  40. penreverse
  41. setxy :x+:w :y
  42. setxy :x+:w :y+:h
  43. setxy :x    :y+:h
  44. setxy :x    :y
  45. pu
  46. end
  47.  
  48. to inanybox :pos :boxs
  49. if emptyp :boxs [output "false]
  50. if inbox :pos last first :boxs [make "select first :boxs output "true]
  51. output inanybox :pos butfirst :boxs
  52. end
  53.  
  54. to inbox :pos :box
  55. make "xp first :pos
  56. make "yp last :pos
  57. make "xb first :box
  58. make "yb first butfirst :box
  59. make "wb first butfirst butfirst :box
  60. make "hb last :box
  61. if :xp > :xb+:wb [output "false]
  62. if :xp < :xb     [output "false]
  63. if :yp > :yb+:hb [output "false]
  64. if :yp < :yb     [output "false]
  65. output "true
  66. end
  67.  
  68. to lbtndown
  69. make "posd mousepos
  70. if inanybox :posd :master [selectbox :select make "boxisselected "true make "backupselect :select] 
  71. make "mousedn "true
  72. end
  73.  
  74. to lbtndowndel
  75. make "posd mousepos
  76. if inanybox :posd :master~
  77.    [~
  78.    setpensize [2 2]~
  79.    drawbox last :select~
  80.    make "master remove :select :master~
  81.    ]
  82. end
  83.  
  84. to lbtnup
  85. if :boxisselected~
  86.   [~
  87.   make "boxisselected "false~
  88.   unselectbox :select~
  89.   make "master remove :backupselect :master~
  90.   make "master lput :select :master~
  91.   ]
  92. make "mousedn "false
  93. end
  94.  
  95. to mmove
  96.   make "posm mousepos
  97.   if :boxisselected~
  98.     [~
  99.     setpensize [4 4]~
  100.     drawbox last :select~
  101.     make "select lput fput first :posm fput last :posm butfirst butfirst last :select butlast :select~
  102.     drawbox last :select~
  103.     make "posd :posm~
  104.     ]
  105. end
  106.  
  107. to newbutton
  108. mouseon [lbtndown] [lbtnup] [] [] [mmove]
  109. make "name readlist
  110. make "mousedn "false
  111. make "boxisselected "false
  112. make "master lput ["button :name [0 0 25 25]] :master
  113. setpensize [2 2]
  114. drawbox last last :master
  115. end
  116.  
  117. to selectbox :box
  118. setpensize [2 2]
  119. drawbox last :box
  120. setpensize [4 4]
  121. drawbox last :box
  122. end
  123.  
  124. to unselectbox :box
  125. setpensize [4 4]
  126. drawbox last :box
  127. setpensize [2 2]
  128. drawbox last :box
  129. end
  130.  
  131. to visual
  132. ht
  133. pu
  134. setpensize [2 2]
  135. make "master []
  136. dowindows
  137. end
  138.  
  139. to visualend
  140. windowdelete "dlg
  141. mouseoff
  142. st
  143. cs
  144. end
  145.